import React, { useState, useEffect } from "react"

export default function StateDemo() {
  const [count, setCount] = useState(0)
  useEffect(() => {
    console.log('第二个数组写了监听的参数,相当于didUpdate')
    return () => {
      console.log('相当于willUnmount生命周期钩子')
    }

  }, [count])

  return (
    <div>
      <h2>useState的使用</h2>
      <h3>点前计数: {count}</h3>
      <button onClick={() => setCount(count + 1)}>+1</button>
    </div>
  )
}